# -*- coding:UTF-8 -*-
# coding:utf-8
import scrapy
from scrapy_test.items import ScrapyTestItem
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from scrapy.loader import ItemLoader


#http://1024.stv919.net/pw/

class ComicSpider(scrapy.Spider):
	name = "dydao"
	# 减慢爬取速度 为1s
	download_delay = 1
	allowed_domains = ["www.dydao.top"]
	start_urls = ['https://music.douban.com/artists/genre_page/5/']


	def start_requests(self):
		self.log('>>>>>>>>>>>>>>>>>>')
		urls = ['http://www.dydao.top/9865.html']
		for url in urls:
			yield scrapy.Request(url=url, callback=self.parse)

	def parse(self, response):
		##item=ScrapyTestItem()  $('.hot_blog li a')[1].text
		## 返回list
		## 返回生成器
		## 返回字典
		## scrapy.Request
		l =ScrapyTestItem()
		items=[]
		#items=[]  $('.single-content img')[0].src
		for i in response.css('.single-content img::attr(src)').extract():
			items.append({'title':'hello','image_urls':[i],'file_urls':[i],'images':[i]})

		return items

		# article_url = str(response.url)
		# article_name = response.xpath('//div[@id="article_details"]/div/h1/span/a/text()').extract()
		# l['title']=[n.encode('utf-8') for n in article_name]
		# l['link']= article_url.encode('utf-8')
		# yield l
		#
		##yield scrapy.Request(url=response.xpath('//li[@class="next_article"]/a/@href').extract_first(),callback=self.parse)




